#include "MultiModel.h"

MultiModel::MultiModel(Model *model, char *filename, CGparameter modelMatrix)
{
	this ->model = model;
	this ->modelMatrix = modelMatrix;

	FileHolder *fh = new FileHolder();
	fh ->openToRead(filename);

	modelsCount = fh ->readInt();
	worldMetrices = new float * [modelsCount];

	for (int i = 0; i < modelsCount; i++)
	{
		fh ->readInt();
		worldMetrices[i] = new float[16];
		fh ->readBuffer((BYTE*)worldMetrices[i], sizeof(float) * 16);
	}

	fh ->close();
	delete fh;
}

void MultiModel::Process(float ms)
{
}

void MultiModel::Render()
{
	//modelsCount = 2;
	for (int i = 0; i < modelsCount; i++)
	{
		glPushMatrix();
		glMultMatrixf(worldMetrices[i]);
		cgGLSetMatrixParameterfc(modelMatrix, worldMetrices[i]);
		model ->Render();
		glPopMatrix();
	}
}
